package com.jack.payment.constant.enums;

import com.jack.payment.constant.ResultHintConstant;
import com.jack.payment.entity.common.BusinessException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 账单状态枚举
 */
public enum BillingStatusEnum {
    PAY(0),             // 支付
    REFUND(1),          // 退款
    WITHDRAW(2)         // 提现
    ;
    private static Logger log = LoggerFactory.getLogger(BillingStatusEnum.class);


    private Integer stat;

    BillingStatusEnum(Integer stat) {
        this.stat = stat;
    }



    public Integer getStat() {
        return stat;
    }

    public static BillingStatusEnum getBillingStatus(Integer index) throws BusinessException {
        Integer length = BillingStatusEnum.values().length;
        if (index > length) {
            log.error("billing 流水状态获取枚举下标越界{}, 确保获取下标小于{}", index, length);
            throw new BusinessException(ResultHintConstant.ENUM_ERROR);
        }
        return BillingStatusEnum.values()[index];
    }
}
